package com.googlecode.ebasys.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Group entity.
 * TODO more comments
 *
 * @author Tomas Varaneckas
 * @version $Id: Group.java 58 2009-01-22 20:49:29Z tomas.varaneckas $
 */
@Entity
@Table(name="eba_group")
public class Group extends PersistentEntity {

    /**
     * Serial Version UID
     */
    private static final long serialVersionUID = -144103447282084149L;
    
    /**
     * Group name
     */
    private String name;
    
    /**
     * Users in this group
     */
    @ManyToMany(targetEntity=User.class, cascade=CascadeType.PERSIST, mappedBy="groups")
    private List<User> users;

    /**
     * Gets the group name
     * 
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the group name
     * 
     * @param name
     */
    public void setName(final String name) {
        this.name = name;
    }

    /**
     * Gets the list of {@link User}s
     * 
     * @return users in this group
     */
    public List<User> getUsers() {
        if (users == null) {
            users = new ArrayList<User>();
        }
        return users;
    }

    /**
     * Sets the list of {@link User}s
     * 
     * @param users users in this group
     */
    public void setUsers(final List<User> users) {
        this.users = users;
    }

}
